// https://blog.csdn.net/a410974689/article/details/116982285

#ifndef YHAIDA_RPCSERVER_H
#define YHAIDA_RPCSERVER_H

#include "../../server/net/TcpServer.h"
#include "../../server/logging/Logging.h"
#include "RpcChannel.h"
#include <lua.hpp>


namespace google
{
    namespace protobuf
    {
        class Service;
    } 
}

namespace yhaida
{
    namespace rpc
    {
        class RpcServer
        {
        public:
            RpcServer(EventLoop *loop,
                      const InetAddress &listenAddr);

            void setThreadNum(int numThreads)
            {
                _server.setThreadNum(numThreads);
            }
            /**
             * @brief 注册->map
             *
             */
            void registerService(::google::protobuf::Service *);
            void start();

        private:
            void onConnection(const TcpConnectionPtr &conn);

            // void onMessage(const TcpConnectionPtr& conn,
            //                Buffer* buf,
            //                Timestamp time);
        private:
            TcpServer _server;
            std::map<std::string, ::google::protobuf::Service *> _services;
        };

    } 
} 

#endif
